home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-ARM / ARCH-VNC / IO.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  177 lines

  1. /*
  2.  * linux/include/asm-arm/arch-ebsa110/io.h
  3.  *
  4.  * Copyright (C) 1997,1998 Russell King
  5.  *
  6.  * Modifications:
  7.  *  06-Dec-1997    RMK    Created.
  8.  */
  9. #ifndef __ASM_ARM_ARCH_IO_H
  10. #define __ASM_ARM_ARCH_IO_H
  11.  
  12. /*
  13.  * This architecture does not require any delayed IO, and
  14.  * has the constant-optimised IO
  15.  */
  16. #undef    ARCH_IO_DELAY
  17.  
  18. /*
  19.  * Dynamic IO functions - let the compiler
  20.  * optimize the expressions
  21.  */
  22. #define DECLARE_DYN_OUT(fnsuffix,instr,typ)                    \
  23. extern __inline__ void __out##fnsuffix (unsigned int value, unsigned int port)    \
  24. {                                        \
  25.     __asm__ __volatile__(                            \
  26.     "str%?" ##instr## "    %0, [%1, %2]        @ out"###fnsuffix    \
  27.     :                                     \
  28.     : "r" (value), "r" (PCIO_BASE), typ (port));                \
  29. }
  30.  
  31. #define DECLARE_DYN_IN(sz,fnsuffix,instr,typ)                    \
  32. extern __inline__ unsigned sz __in##fnsuffix (unsigned int port)        \
  33. {                                        \
  34.     unsigned long value;                            \
  35.     __asm__ __volatile__(                            \
  36.     "ldr%?" ##instr## "    %0, [%1, %2]        @ in"###fnsuffix    \
  37.     : "=&r" (value)                                \
  38.     : "r" (PCIO_BASE), typ (port));                        \
  39.     return (unsigned sz)value;                        \
  40. }
  41.  
  42. extern __inline__ unsigned int __ioaddr (unsigned int port)            \
  43. {                                        \
  44.     return (unsigned int)(PCIO_BASE + port);                \
  45. }
  46.  
  47. #define DECLARE_IO(sz,fnsuffix,instr,typ)    \
  48.     DECLARE_DYN_OUT(fnsuffix,instr,typ)    \
  49.     DECLARE_DYN_IN(sz,fnsuffix,instr,typ)
  50.  
  51. DECLARE_IO(char,b,"b","Jr")
  52. DECLARE_IO(short,w,"h","r")
  53. DECLARE_IO(long,l,"","Jr")
  54.  
  55. #undef DECLARE_IO
  56. #undef DECLARE_DYN_OUT
  57. #undef DECLARE_DYN_IN
  58.  
  59. /*
  60.  * Constant address IO functions
  61.  *
  62.  * These have to be macros for the 'J' constraint to work -
  63.  * +/-4096 immediate operand.
  64.  */
  65. #define __outbc(value,port)                            \
  66. ({                                        \
  67.     __asm__ __volatile__(                            \
  68.     "strb    %0, [%1, %2]                @ outbc"        \
  69.     :                                    \
  70.     : "r" (value), "r" (PCIO_BASE), "Jr" (port));                \
  71. })
  72.  
  73. #define __inbc(port)                                \
  74. ({                                        \
  75.     unsigned char result;                            \
  76.     __asm__ __volatile__(                            \
  77.     "ldrb    %0, [%1, %2]                @ inbc"            \
  78.     : "=r" (result)                                \
  79.     : "r" (PCIO_BASE), "Jr" (port));                    \
  80.     result;                                    \
  81. })
  82.  
  83. #define __outwc(value,port)                            \
  84. ({                                        \
  85.     __asm__ __volatile__(                            \
  86.     "strh    %0, [%1, %2]                @ outwc"        \
  87.     :                                    \
  88.     : "r" (value), "r" (PCIO_BASE), "r" (port));                \
  89. })
  90.  
  91. #define __inwc(port)                                \
  92. ({                                        \
  93.     unsigned short result;                            \
  94.     __asm__ __volatile__(                            \
  95.     "ldrh    %0, [%1, %2]                @ inwc"            \
  96.     : "=r" (result)                                \
  97.     : "r" (PCIO_BASE), "r" (port));                        \
  98.     result & 0xffff;                            \
  99. })
  100.  
  101. #define __outlc(value,port)                            \
  102. ({                                        \
  103.     __asm__ __volatile__(                            \
  104.     "str    %0, [%1, %2]                @ outlc"        \
  105.     :                                    \
  106.     : "r" (value), "r" (PCIO_BASE), "Jr" (port));                \
  107. })
  108.  
  109. #define __inlc(port)                                \
  110. ({                                        \
  111.     unsigned long result;                            \
  112.     __asm__ __volatile__(                            \
  113.     "ldr    %0, [%1, %2]                @ inlc"            \
  114.     : "=r" (result)                                \
  115.     : "r" (PCIO_BASE), "Jr" (port));                    \
  116.     result;                                    \
  117. })
  118.  
  119. #define __ioaddrc(port)                                \
  120. ({                                        \
  121.     unsigned long addr;                            \
  122.     addr = PCIO_BASE + port;                        \
  123.     addr;                                    \
  124. })
  125.  
  126. /*
  127.  * Translated address IO functions
  128.  *
  129.  * IO address has already been translated to a virtual address
  130.  */
  131. #define outb_t(v,p)                                \
  132.     (*(volatile unsigned char *)(p) = (v))
  133.  
  134. #define inb_t(p)                                \
  135.     (*(volatile unsigned char *)(p))
  136.  
  137. #define outl_t(v,p)                                \
  138.     (*(volatile unsigned long *)(p) = (v))
  139.  
  140. #define inl_t(p)                                \
  141.     (*(volatile unsigned long *)(p))
  142.  
  143. /*
  144.  * This is not sufficient... (and it's a hack anyway)
  145.  */
  146. static inline void writeb(unsigned char b, unsigned int addr)
  147. {
  148.     *(volatile unsigned char *)(0xe0000000 + (addr)) = b;
  149. }
  150.  
  151. static inline unsigned char readb(unsigned int addr)
  152. {
  153.     return *(volatile unsigned char *)(0xe0000000 + (addr));
  154. }
  155.  
  156. static inline void writew(unsigned short b, unsigned int addr)
  157. {
  158.     *(volatile unsigned short *)(0xe0000000 + (addr)) = b;
  159. }
  160.  
  161. static inline unsigned short readw(unsigned int addr)
  162. {
  163.     return *(volatile unsigned short *)(0xe0000000 + (addr));
  164. }
  165.  
  166. static inline void writel(unsigned long b, unsigned int addr)
  167. {
  168.     *(volatile unsigned long *)(0xe0000000 + (addr)) = b;
  169. }
  170.  
  171. static inline unsigned long readl(unsigned int addr)
  172. {
  173.     return *(volatile unsigned long *)(0xe0000000 + (addr));
  174. }
  175.  
  176. #endif
  177.